using System.Collections.Generic;
using System.Text.Json.Serialization;
using JlPay.Sdk.Models;
using JlPay.Sdk.Services;

namespace JlPay.Sdk.Models.Openmerch.Change
{
    /// <summary>
    /// 结算账户变更请求
    /// </summary>
    public class SettleAccountChangeRequest : OrgBaseRequest, IRequestMapper
    {
        /// <summary>
        /// API URL
        /// </summary>
        public const string API_URL = "/open/merch/access/settle-info/modify";

        /// <summary>
        /// 业务申请编号
        /// </summary>
        [JsonPropertyName("apply_id")]
        public string? ApplyId { get; set; }

        /// <summary>
        /// 结算类型
        /// </summary>
        [JsonPropertyName("settle_type")]
        public string? SettleType { get; set; }

        /// <summary>
        /// 结算账户名
        /// </summary>
        [JsonPropertyName("account_name")]
        public string? AccountName { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        [JsonPropertyName("account_no")]
        public string? AccountNo { get; set; }

        /// <summary>
        /// 银行代码
        /// </summary>
        [JsonPropertyName("bank_code")]
        public string? BankCode { get; set; }

        /// <summary>
        /// 银行支行联行号
        /// </summary>
        [JsonPropertyName("bank_branch_id")]
        public string? BankBranchId { get; set; }

        /// <summary>
        /// 银行支行名称
        /// </summary>
        [JsonPropertyName("bank_branch_name")]
        public string? BankBranchName { get; set; }

        /// <summary>
        /// 账户图片
        /// </summary>
        [JsonPropertyName("account_pic")]
        public string? AccountPic { get; set; }

        /// <summary>
        /// 预留银行手机号码
        /// </summary>
        [JsonPropertyName("bank_set_phone")]
        public string? BankSetPhone { get; set; }

        /// <summary>
        /// 证件类型
        /// </summary>
        [JsonPropertyName("cert_type")]
        public string? CertType { get; set; }

        /// <summary>
        /// 收款人证件号码
        /// </summary>
        [JsonPropertyName("delegatee_id_card")]
        public string? DelegateeIdCard { get; set; }

        /// <summary>
        /// 证件有效期开始
        /// </summary>
        [JsonPropertyName("delegatee_cert_period_begin")]
        public string? DelegateeCertPeriodBegin { get; set; }

        /// <summary>
        /// 证件有效期结束
        /// </summary>
        [JsonPropertyName("delegatee_cert_period_end")]
        public string? DelegateeCertPeriodEnd { get; set; }

        /// <summary>
        /// 账户许可证
        /// </summary>
        [JsonPropertyName("acct_license")]
        public string? AcctLicense { get; set; }

        /// <summary>
        /// 账户证件正面图片
        /// </summary>
        [JsonPropertyName("acct_cert_front_pic")]
        public string? AcctCertFrontPic { get; set; }

        /// <summary>
        /// 账户证件背面图片
        /// </summary>
        [JsonPropertyName("acct_cert_back_pic")]
        public string? AcctCertBackPic { get; set; }

        /// <summary>
        /// 账户授权书
        /// </summary>
        [JsonPropertyName("acct_auth_letter")]
        public string? AcctAuthLetter { get; set; }

        /// <summary>
        /// 身份人脸图片
        /// </summary>
        [JsonPropertyName("identity_face_pic")]
        public string? IdentityFacePic { get; set; }

        /// <summary>
        /// 账户人脸图片
        /// </summary>
        [JsonPropertyName("acct_face_pic")]
        public string? AcctFacePic { get; set; }

        /// <summary>
        /// 辅助证明材料
        /// </summary>
        [JsonPropertyName("proof_info")]
        public List<Dictionary<string, object>>? ProofInfo { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public SettleAccountChangeRequest()
        {
            // 添加敏感字段
            AddSensitiveField("account_name");
            AddSensitiveField("account_no");
            AddSensitiveField("bank_set_phone");
            AddSensitiveField("delegatee_id_card");
        }

        /// <summary>
        /// 转换为字典
        /// </summary>
        /// <returns>字典对象</returns>
        public Dictionary<string, object> ToMap()
        {
            var map = new Dictionary<string, object>();

            // 添加基础字段
            if (!string.IsNullOrEmpty(OrgNo))
                map["org_no"] = OrgNo;
            if (!string.IsNullOrEmpty(MerchNo))
                map["merch_no"] = MerchNo;

            // 添加其他字段
            if (!string.IsNullOrEmpty(ApplyId))
                map["apply_id"] = ApplyId;
            if (!string.IsNullOrEmpty(SettleType))
                map["settle_type"] = SettleType;
            if (!string.IsNullOrEmpty(AccountName))
                map["account_name"] = AccountName;
            if (!string.IsNullOrEmpty(AccountNo))
                map["account_no"] = AccountNo;
            if (!string.IsNullOrEmpty(BankCode))
                map["bank_code"] = BankCode;
            if (!string.IsNullOrEmpty(BankBranchId))
                map["bank_branch_id"] = BankBranchId;
            if (!string.IsNullOrEmpty(BankBranchName))
                map["bank_branch_name"] = BankBranchName;
            if (!string.IsNullOrEmpty(AccountPic))
                map["account_pic"] = AccountPic;
            if (!string.IsNullOrEmpty(BankSetPhone))
                map["bank_set_phone"] = BankSetPhone;
            if (!string.IsNullOrEmpty(CertType))
                map["cert_type"] = CertType;
            if (!string.IsNullOrEmpty(DelegateeIdCard))
                map["delegatee_id_card"] = DelegateeIdCard;
            if (!string.IsNullOrEmpty(DelegateeCertPeriodBegin))
                map["delegatee_cert_period_begin"] = DelegateeCertPeriodBegin;
            if (!string.IsNullOrEmpty(DelegateeCertPeriodEnd))
                map["delegatee_cert_period_end"] = DelegateeCertPeriodEnd;
            if (!string.IsNullOrEmpty(AcctLicense))
                map["acct_license"] = AcctLicense;
            if (!string.IsNullOrEmpty(AcctCertFrontPic))
                map["acct_cert_front_pic"] = AcctCertFrontPic;
            if (!string.IsNullOrEmpty(AcctCertBackPic))
                map["acct_cert_back_pic"] = AcctCertBackPic;
            if (!string.IsNullOrEmpty(AcctAuthLetter))
                map["acct_auth_letter"] = AcctAuthLetter;
            if (!string.IsNullOrEmpty(IdentityFacePic))
                map["identity_face_pic"] = IdentityFacePic;
            if (!string.IsNullOrEmpty(AcctFacePic))
                map["acct_face_pic"] = AcctFacePic;

            // 添加复杂对象字段
            if (ProofInfo != null && ProofInfo.Count > 0)
                map["proof_info"] = ProofInfo;

            return map;
        }
    }
} 